<%--
  Created by IntelliJ IDEA.
  User: Mr.Cai
  Date: 2021/3/2
  Time: 9:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="../css/mymain.mymain.css">
    <script type="application/javascript" src="../js/jquery-3.3.1.js"></script>
    <script type="application/javascript" src="../js/bootstrap.min.js"></script>
    <script type="application/javascript" src="../layui/layui.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <style>
        .myInput{
            margin-left: 100px;
            width: 200px;
            height: 38px;
        }
    </style>
</head>
<body>


<table style="width: 90%;margin: 5px auto"  class="layui-table" id="mytable">

    <input type="number" value="" id="id"  placeholder="请输入用户id" class="myInput">
    <button id="byID" value="确定查询"  class="layui-btn">根据用户id查询</button>


    <hr>

</table>

<script>

    $("#byID").click(function () {

        let uid ={
            "uid":$("#id").val()
        };

        $.ajax({
            url:"/order/selectOrdersByUser",
            data:JSON.stringify(uid),
            type:"post",
            contentType:'application/json',
            dataType:"json",


            success:function (order) {
                alert(333);
                $("#mytable").empty()  //清空元素的所有子节点
                $("#mytable").append(
                    "            <tr>\n" +
                    "                <td>订单号</td>\n" +
                    "                <td>订单金额</td>\n" +
                    "                <td>所属用户</td>\n" +
                    "                <td>车辆名称</td>\n" +
                    "                <td>车辆类型</td>\n" +
                    "                <td>车辆座位数</td>\n" +
                    "                <td>车辆日租金</td>\n" +
                    "                <td>取车地址</td>\n" +
                    "                <td>还车地址</td>\n" +
                    "                <td>订单状态</td>\n" +
                    "                <td> 操作</td>\n" +
                    "            </tr>"
                )
                for (let o of order) {
                    $("#mytable").append(
                        "                <tr>\n" +
                        "                    <td>"+o.id+"</td>\n" +
                        "                    <td>"+o.oprice+"</td>\n" +
                        "                    <td>"+o.user.tel+"</td>\n" +
                        "                    <td>"+o.car.name+"</td>\n" +
                        "                    <td>"+o.car.type+"</td>\n" +
                        "                    <td>"+o.car.sitnum+"</td>\n" +
                        "                    <td>"+o.car.price+"</td>\n" +
                        "                    <td>"+o.getAddr.name+"</td>\n" +
                        "                    <td>"+o.backAddr.name+"</td>\n" +
                        "                    <td>"+o.status+"</td>\n" +
                        "                    <td>"+"\n" +
                        "                        <a href=\"/user/selectOne?id="+o.id+"\">修改</a>\n" +
                        "                        <a href=\"/user/delete?id="+o.id+"\" onclick=\"reDelete()\" class=\"myDelete\">删除</a>\n" +
                        "                    "+"</td>\n" +
                        "                </tr>"
                    )
                }
            }

        });
    });
</script>
</body>
</html>
